<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>执行搜索查询</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="sphinxclient.open.html">SphinxClient::open</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="sphinxclient.resetfilters.html">SphinxClient::resetFilters</a></div>
 <div class="up"><a href="class.sphinxclient.html">SphinxClient</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="sphinxclient.query" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SphinxClient::query</h1>
  <p class="verinfo">(PECL sphinx &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">SphinxClient::query</span> &mdash; <span class="dc-title">执行搜索查询</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-sphinxclient.query-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">array</span> <span class="methodname"><strong>SphinxClient::query</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$query</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$index</code><span class="initializer"> = &quot;*&quot;</span></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$comment</code><span class="initializer"> = &quot;&quot;</span></span>
  ]] )</div>

  <p class="para rdfs-comment">
   连接到searchd服务器，根据服务器的当前设置执行给定的查询，取得并返回结果集.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-sphinxclient.query-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">query</code></em></dt>

     <dd>

      <p class="para">
      查询字符串.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">index</code></em></dt>

     <dd>

      <p class="para">
       索引名称 (可以为多个，使用逗号分割，或者为“*”表示全部索引).
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">comment</code></em></dt>

     <dd>

      <p class="para">
      发送到searchd的查询日志的注释内容
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-sphinxclient.query-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   如果搜索成功, <span class="function"><strong>SphinxClient::query()</strong></span> 返回的结果集列表包含找到的全部匹配项中的一部分，以及与查询相关的统计数据. 结果集是哈希结构，包含如下键和值:
   <table class="doctable table">
    <caption><strong>返回数据结构</strong></caption>
    
     <thead>
      <tr>
       <th>键</th>
       <th>值说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>&quot;matches&quot;</td>
       <td>存储文档ID以及其对应的另一个包含文档权重和属性值的hash表</td>
      </tr>

      <tr>
       <td>&quot;total&quot;</td>
       <td>此查询在服务器检索所得的匹配文档总数（即服务器端结果集的大小，且与相关设置有关） </td>
      </tr>

      <tr>
       <td>&quot;total_found&quot;</td>
       <td>（服务器上找到和处理了的）索引中匹配文档的总数</td>
      </tr>

      <tr>
       <td>&quot;words&quot;</td>
       <td>将查询关键字（关键字已经过大小写转换，取词干和其他处理）映射到一个包含关于关键字的统计数据（“docs”——在多少文档中出现，“hits”——共出现了多少次）的小hash表上。</td>
      </tr>

      <tr>
       <td>&quot;error&quot;</td>
       <td>searchd报告的错误信息</td>
      </tr>

      <tr>
       <td>&quot;warning&quot;</td>
       <td>searchd报告的警告信息</td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-sphinxclient.query-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><a href="sphinxclient.runqueries.html" class="xref">SphinxClient::runQueries</a></li>
    <li class="member"><a href="sphinxclient.addquery.html" class="xref">SphinxClient::addQuery</a></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="sphinxclient.open.html">SphinxClient::open</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="sphinxclient.resetfilters.html">SphinxClient::resetFilters</a></div>
 <div class="up"><a href="class.sphinxclient.html">SphinxClient</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
